<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>demo</title>
    <script type="text/javascript" src="../vue.js"></script>
    <style>
        .login {
          background-color: yellowgreen;
        }
    
        .register {
          background-color: pink;
        }
      </style>
</head>

<body>
    <div id="app">
        <button @click="isLogin=true">登录</button>
        <button @click="isLogin=false">注册</button>

        <h1>
            请{{isLogin?"登录":"注册"}}
        </h1>
        <form action="###" v-if="isLogin" class="login" key="login">
            <input type="text" name="username">
            <input type="password" name="password">
          </form>
          <form action="###" v-else class="register" key="register">
            <input type="text" name="username">
            <input type="password" name="password">
          </form>
    </div>
</body>
<script type="text/javascript">
    Vue.config.productionTip = false
    const vm = new Vue({
        el: "#app",
        data() {
            return {
          isLogin: true
        }
        }
    })
</script>

</html>